//AutoTrimps Settings GUI - Current Version 2.1.6.9
//maintained by genBTC, current as of 3/20/2018

//create the Automation icon in the game bar (self-executing)
//This creates the entire DOM-structure for this page.
function automationMenuInit() {
    var settingBtnSrch = document.getElementsByClassName("btn btn-default");
    //Change Settings button handler to go through AutoTrimps Settings
    for (var i = 0; i < settingBtnSrch.length; i++) {
        if (settingBtnSrch[i].getAttribute("onclick") === "toggleSettingsMenu()")
            settingBtnSrch[i].setAttribute("onclick", "autoPlusSettingsMenu()");
    }
    //create the AutoTrimps Script button (bottom toolbar)
    var newItem = document.createElement("TD");
    newItem.appendChild(document.createTextNode("脆皮自动脚本"));
    newItem.setAttribute("class", "btn btn-default");
    newItem.setAttribute("onclick", "autoToggle()");
    var settingbarRow = document.getElementById("settingsTable").firstElementChild.firstElementChild;
    settingbarRow.insertBefore(newItem, settingbarRow.childNodes[10]);

    //create automaps button (in the world sidebar)
    var newContainer = document.createElement("DIV");
    //newContainer.setAttribute("class", "battleSideBtnContainer");
    newContainer.setAttribute("style", "margin-top: 0.2vw; display: block; font-size: 1.1vw; height: 1.5em; text-align: center; border-radius: 4px");
    newContainer.setAttribute("id", "autoMapBtn");
    newContainer.setAttribute("class", "noselect settingsBtn");
    newContainer.setAttribute("onClick", "toggleAutoMaps()");
    newContainer.setAttribute("onmouseover", 'tooltip(\"Toggle Automapping\", \"customText\", event, \"Toggle automapping on and off.\")');
    newContainer.setAttribute("onmouseout", 'tooltip("hide")');
    var abutton = document.createElement("SPAN");
    abutton.appendChild(document.createTextNode("自动地图"));
    abutton.setAttribute("id", "autoMapLabel");
    var fightButtonCol = document.getElementById("battleBtnsColumn");
    newContainer.appendChild(abutton);
    fightButtonCol.appendChild(newContainer);

    //create automaps status (in the world sidebar)
    newContainer = document.createElement("DIV");
    newContainer.setAttribute("style", "display: block; font-size: 1.1vw; text-align: center; background-color: rgba(0,0,0,0.3);");
    newContainer.setAttribute("onmouseover", 'tooltip(\"生命伤害比\", \"customText\", event, \"这个状态框是当自动地图模式开启的情况下出现的。上面会显示 挂机 模式或是 需要更多伤害 模式，此时显示的数字是 \'生命伤害比\' 。意思是敌人的生命与你的伤害之间的比值 (在 X 层叠加下). 这个比超过16将触发挂机模式，超过4将触发叠加地图加成到10层。<p><b>足够的生命: </b>\" + enoughHealth + \"<br><b>足够的伤害: </b>\" + enoughDamage +\"<br><b>应当挂机: </b>\" + shouldFarm +\"<br><b>生命伤害比 = </b>\" + HDratio + \"<br>\")');
    newContainer.setAttribute("onmouseout", 'tooltip("hide")');
    abutton = document.createElement("SPAN");
    abutton.id = 'autoMapStatus';
    newContainer.appendChild(abutton);
    fightButtonCol.appendChild(newContainer);

    //create hiderStatus - He/hr percent (in world sidebar)
    newContainer = document.createElement("DIV");
    newContainer.setAttribute("style", "display: block; font-size: 1vw; text-align: center; margin-top: 2px; background-color: rgba(0,0,0,0.3);");
    newContainer.setAttribute("onmouseover", 'tooltip(\"氦/小时 信息\", \"customText\", event, \"第一行是你本轮平均每小时获得的氦 占整个游戏所获氦的百分比(不包括本轮获得+未使用的).<br> 0.5% 是一个理想的峰值目标.这个可以告诉你什么时候进入传送门... <br>第二行是本轮所获得的总共的氦 占整个游戏中所获得的氦的百分比(不包括本轮)<br>\" + getDailyHeHrStats())');
    newContainer.setAttribute("onmouseout", 'tooltip("hide")');
    abutton = document.createElement("SPAN");
    abutton.id = 'hiderStatus';
    newContainer.appendChild(abutton);
    fightButtonCol.appendChild(newContainer);

    //make timer clock toggle paused mode when clicked (bottom right)
    var $portalTimer = document.getElementById('portalTimer');
    $portalTimer.setAttribute('onclick', 'toggleSetting(\'pauseGame\')');
    $portalTimer.setAttribute('style', 'cursor: default');

    //shrink padding for fight buttons to help fit automaps button/status
    var btns = document.getElementsByClassName("fightBtn");
    for (var x = 0; x < btns.length; x++) {
        btns[x].style.padding = "0.01vw 0.01vw";
    }
}
automationMenuInit();

//create container for settings buttons (this is seperate because it needs to
//  be re-run seperately to reset when importing)
function automationMenuSettingsInit() {
    var settingsrow = document.getElementById("settingsRow");
    var autoSettings = document.createElement("DIV");
    autoSettings.id = "autoSettings";
    autoSettings.setAttribute("style", "display: none; max-height: 92.5vh;overflow: auto;");
    settingsrow.appendChild(autoSettings);
}
automationMenuSettingsInit();

//prepare CSS for new Tab interface
var link1 = document.createElement('link');
link1.rel = "stylesheet";
link1.type = "text/css";
link1.href = basepath + 'tabs.css';
document.head.appendChild(link1);

//Tab make helperfunctions
function createTabs(name, description) {
    var li_0 = document.createElement('li');
    var a_0 = document.createElement('a');
    a_0.className = "tablinks";
    a_0.setAttribute('onclick', 'toggleTab(event, \'' + name + '\')');
    a_0.href = "#";
    a_0.appendChild(document.createTextNode(cnname(name)));
    li_0.id = 'tab' + name;
    li_0.appendChild(a_0);
    addtabsUL.appendChild(li_0);
    createTabContents(name, description);
}

function createTabContents(name, description) {
    var div_0 = document.createElement('div');
    div_0.className = "tabcontent";
    div_0.id = name;
    var div_1 = document.createElement('div');
    div_1.setAttribute("style", "margin-left: 1vw; margin-right: 1vw;");
    var h4_0 = document.createElement('h4');
    h4_0.setAttribute('style', 'font-size: 1.2vw;');
    h4_0.appendChild(document.createTextNode(description));
    div_1.appendChild(h4_0);
    div_0.appendChild(div_1);
    addTabsDiv.appendChild(div_0);
}

//Toggle handler (onclick)
function toggleTab(evt, tabName) {
    if (evt.currentTarget.className.indexOf(" active") > -1) {
        document.getElementById(tabName).style.display = "none";
        evt.currentTarget.className = evt.currentTarget.className.replace(" active", "");
    } else {
        document.getElementById(tabName).style.display = "block";
        evt.currentTarget.className += " active";
    }
}

//Minimize button handler
function minimizeAllTabs() {
    // Get all elements with class="tabcontent" and hide them
    var tabcontent = document.getElementsByClassName("tabcontent");
    for (var i = 0,len = tabcontent.length; i < len ; i++) {
        tabcontent[i].style.display = "none";
    }
    // Get all elements with class="tablinks" and remove the class "active"
    var tablinks = document.getElementsByClassName("tablinks");
    for (var i = 0,len = tablinks.length; i < len ; i++) {
        // if (!(tablinks[i].className.includes('minimize') || tablinks[i].className.includes('maximize') || tablinks[i].className.includes('tabclose') || tablinks[i].parentNode.id.includes('tabCore')))
            // tablinks[i].style.display = "none";
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
}

//Minimize button handler
function maximizeAllTabs() {
    // Get all elements with class="tabcontent" and show them
    var tabcontent = document.getElementsByClassName("tabcontent");
    for (var i = 0,len = tabcontent.length; i < len ; i++) {
        tabcontent[i].style.display = "block";
    }
    // Get all elements with class="tablinks" and add the class "active"
    var tablinks = document.getElementsByClassName("tablinks");
    for (var i = 0,len = tablinks.length; i < len ; i++) {
        tablinks[i].style.display = "block";
        if (!tablinks[i].className.includes(' active'))
            tablinks[i].className += " active";
    }
}

var addTabsDiv;
var addtabsUL;
//Actually Make the Tabs
function initializeAllTabs() {
    //CREATE TABS + CONTENT
    addTabsDiv = document.createElement('div');
    addtabsUL = document.createElement('ul');
    addtabsUL.className = "tab";
    addtabsUL.id = 'autoTrimpsTabBarMenu';
    addtabsUL.style.display = "none";
    //Pin settings Tab Bar to the top like the other bar?
    var sh = document.getElementById("settingsRow")
    sh.insertBefore(addtabsUL, sh.childNodes[2]);
    //addTabsDiv.appendChild(addtabsUL);
    //Then it has to be maintained and toggled on off.
    //Make Tabs.
    createTabs("Core", "核心 - 脚本的主要控件。");
    createTabs("Buildings", "建筑设置");
    createTabs("Jobs", "工作 - 工人设置");
    createTabs("Gear", "装备 - 装备设置");
    createTabs("Maps", "地图 - 自动地图 & 虚空地图设置");
    createTabs("Combat", "战斗 & 姿态设置");
    createTabs("Scryer", "占卜者设置");
    createTabs("Magma", "维度发生器 & 岩浆岩设置");
    createTabs("Heirlooms", "传家宝设置");
    createTabs("Golden", "金色升级设置");
    createTabs("Nature", "自然设置");
    createTabs("Display", "Display & Spam Settings");
    //createTabs("Modules", "Load/Unload Modules & Settings");
    createTabs("Import Export", "导入 & 导出脚本配置");
    //add a minimize button:
    var li_0 = document.createElement('li');
    var a_0 = document.createElement('a');
    a_0.className = "tablinks minimize";
    a_0.setAttribute('onclick', 'minimizeAllTabs();');
    a_0.href = "#";
    a_0.appendChild(document.createTextNode("-"));
    li_0.appendChild(a_0);
    li_0.setAttribute("style", "float:right!important;");
    li_0.setAttribute("onmouseover",'tooltip("Minimize all tabs", "customText", event, "Minimize all AT settings tabs.")');
    li_0.setAttribute("onmouseout", 'tooltip("hide")');
    //add a maximize button:
    var li_1 = document.createElement('li');
    var a_1 = document.createElement('a');
    a_1.className = "tablinks maximize";
    a_1.setAttribute('onclick', 'maximizeAllTabs();');
    a_1.href = "#";
    a_1.appendChild(document.createTextNode("+"));
    li_1.appendChild(a_1);
    li_1.setAttribute("style", "float:right!important;");
    li_1.setAttribute("onmouseover",'tooltip("Maximize all tabs", "customText", event, "Maximize all AT settings tabs.")');
    li_1.setAttribute("onmouseout", 'tooltip("hide")');
    //add a minimize button:
    var li_2 = document.createElement('li');
    var a_2 = document.createElement('a');
    a_2.className = "tablinks tabclose";
    a_2.setAttribute('onclick', 'autoToggle();');
    a_2.href = "#";
    a_2.appendChild(document.createTextNode("x"));
    li_2.appendChild(a_2);
    li_2.setAttribute("style", "float:right!important;");
    li_2.setAttribute("onmouseover",'tooltip("Exit (duplicate)", "customText", event, "Closes/toggles/hides AutoTrimps (just a UI shortcut)")');
    li_2.setAttribute("onmouseout", 'tooltip("hide")');
    addtabsUL.appendChild(li_2);    //close
    addtabsUL.appendChild(li_1);    //max
    addtabsUL.appendChild(li_0);    //min
    //Insert tabs into the game area
    document.getElementById("autoSettings").appendChild(addTabsDiv);
    //pretend click to make first tab active.
    document.getElementById("Core").style.display = "block";
    document.getElementsByClassName("tablinks")[0].className += " active";
}
initializeAllTabs();

//Actually Make the Settings Buttons
function initializeAllSettings() {
    //START MAKING BUTTONS IN THE TABS:



//CORE:
    //Line1:
    createSetting('ManualGather2', ['手动采集/建造', '自动采集/建造', '自动采集/建造 #2', '科学研究 OFF'], '决定了你能做什么。 手动模式什么都不做<br>选择自动模式1还是2取决于你,它们应该是相似的.自动采集食物、木头、金属(w/turkimp) & 科学。 自动加速建造你的建造序列。<br>你可以关闭研究科学功能，为了达成成就：在达到120层前不手动研究。', 'multitoggle', 1, null, "Core");
    createSetting('BuyUpgradesNew', ['手动升级', '购买所有升级', '不购买协作'], '自动购买非装备升级(装备升级在装备页面中控制)。第二个设置不自动购买协作升级(使用这个设置 <b>只有</b>当你明白你的设置会有什么改变的时候).', 'multitoggle', 1, null, "Core");
    //createSetting('ManageBreedtimerNew', ['Manual Breed Timer', 'Auto Breed Timer', 'Auto No Patience'], '<u>Genetecist management is controlled by the Timer setting box to the right, not this.</u><br><b>Explanation: </b><br><U>[ON](Green): </U>All this does is auto-choose the appropriate timer for various challenges, and accounts for the patience mastery.<br><U>[ON](Yellow): </U>The same as above, but ignores patience and will not set a breed timer longer than 30s.<br><U>[OFF](Red): </U>You set the Timer yourself! Even if this is red, it still tampers with genetecists if the timer is >= 0.<br><b>Note: </b>Using AutoStance is recommended to survive the full 30 seconds or else Auto will probably be undesirable.', 'multitoggle', 1, null, "Core"); //This replaces the two settings below, but do we really need an option to ignore patience??
    createSetting('ManageBreedtimer', '自动繁殖时间', '<u>基因学家的管理是由右侧的时间设定格所控制，而不是这一个。</u><br><b>说明: </b><br><U>[打开](绿色): </U>为不同的挑战自动选择合适的繁殖时间(0, 3.5s, 10s, 30s).<br><U>[关闭](红色): </U>你自己设置繁殖时间!即使本设置在关闭状态，如果遗传学家计时器未禁用，它也会影响计时器。<br><b>Note: </b>建议使用自动姿态来活够30秒，否则本设置可能会令人不快。', 'boolean', true, null, "Core");
    createSetting('GeneticistTimer', '基因学家繁殖时间', '通过雇佣/解雇遗传学家来控制繁殖时间，来设定理想的预期(一项能力)层数。设为-1禁用，即不雇佣/解雇遗传学家。 <br><b>信息:</b> 繁殖效率以及托儿所的购买会被动态调节(禁用本项后将不再停止购买繁殖效率)。自动雇佣遗传学家的过程可以简单地总结为：购买/等待/死亡，重复。(如果你的队伍没有死，将不会进行操作)。当你的\'预期\'层数未达到最大时，也会自杀（也被称作强制遗弃）（保守的）。<p><B>当自动繁殖时间开启时将会自动改变本项(本项会被锁定)</B>。', 'value', '30', null, "Core");
    createSetting('SpireBreedTimer', '尖塔繁殖时间', '在尖塔中本项优先于普通的繁殖时间设置(受到地图页面中\'忽略尖塔直到：\'的影响)。设为-1禁用这项特殊的设置。', 'value', -1, null, 'Core');
    createSetting('BreedFire', '生育解雇', '可选的。 在需要的时候，解雇伐木工和矿工来加速生育。根本来说就是用木材/金属来减少战斗小队死亡后的等待时间。 声明:可能严重影响木材收集。 ', 'boolean', false, null, 'Core');
    createSetting('TrapTrimps', '捕捉脆皮', '在需要的时候自动捕捉脆皮,同时包括了建造陷阱。(当你关掉这个选项，你可能也会关掉游戏内的自动陷阱按钮。想想饥肠辘辘，可能会被陷阱中食物吸引来的脆皮吧！)', 'boolean', true, null, "Core");

    //Line2
    createSetting('AutoStartDaily', '自动开始日常挑战', '当开启时，<b>只要能够</b>做日常挑战，自动传送时将会开启日常挑战。做挑战的顺序为，先做最老的，再逐步做向最新的。当没有日常挑战可做时返回到原来选定的模式。', 'boolean', false, null, 'Core');
    createSetting('AutoFinishDailyNew', '结束日常挑战 层数模式', '“不传送直到层数”以及“定制传送”模式将在<b>只要被触发</b>后就自动完成日常挑战并传送。本设置中你设置一个层数，你将会比正常层数提前/推后这个层数传送。设为负数意味着你将比原来<b>提前</b>传送。设为正数将会<b>推迟</b>到一个较后面的区域。设为0将不改变你正常的自动传送设置。当使用“氦/小时”模式时，本选项<b>不会迫使</b>它自动传送，只有当你的氦/小时下降时才会允许自动传送。如果要在日常挑战中禁用自动传送，关闭自动传送选项，或是将本选项设为<b>999</b>!', 'valueNegative', 999, null, 'Core'); 
    createSetting('FinishC2', '完成挑战2', '如果你正在进行挑战2，当抵达这个区域时完成/放弃挑战2 (所有)。 供手动使用。 建议: 对于大多数挑战2来说，设置为以0结尾的区域。设为-1禁用。没有运行挑战2时无效。', 'value', -1, null, 'Core');
    if (game.worldUnlocks.easterEgg)
    createSetting('AutoEggs', '自动点蛋', '当进入一个新的区域，如果存在复活节彩蛋，自动点击它。 警告: 有些过于强大，影响平衡。请庄严宣誓，你的做法是不好的。', 'boolean', false, null, 'Core'); //could really be removed??
    createSetting('UsePatience', 'Enable Patience', 'Sets the default breed timer to 45 seconds if you have the Patience mastery.', 'boolean', true, null, 'Core');
    createSetting('AutoAllocatePerks', '自动分配能力', '基于提前设置好的自动能力比率，当你 自动进入传送门 时，自动花费你的所有氦来分配能力。不会改变已经固定的能力: 虹吸学, 预期, 冥想, 无情, 范围, 敏捷, 诱饵, 法宝, 包装, capable. ', 'boolean', false, null, 'Core');    
    document.getElementById('AutoAllocatePerks').parentNode.insertAdjacentHTML('afterend','<br>');

    //NewLine3 For Autoportal, it would be nice to add a 5s countdown, like with magma spending.
    createSetting('AutoPortal', '自动传送', '自动进入传送门。 如果你正在做一个挑战的话就不会自动传送，挑战选项决定了下一次传送后自动选择的挑战。选择任一挑战选项将会在挑战完成后立即传送，开始下一轮，不管其他一切条件。氦/小时： 当你的 氦/小时 比起你本轮最高的 氦/小时 低时便会在这层的 <b>第一个房间传送</b> 。注意，有一个缓冲选项，是一个百分比，能够设置在触发自动传送前 氦/小时 能比最高低百分之多少。设置缓冲区后，如果降低值超过了缓冲区的5倍将会在层中传送。  注意: 如果你现在的值低的话，选择 氦/小时 可能会立即传送-(使用“暂停自动脚本”按钮来暂停脚本，以避免这种情况出现)', 'dropdown', 'Off', ['Off', 'Helium Per Hour', 'Balance', 'Decay', 'Electricity', 'Life', 'Crushed', 'Nom', 'Toxicity', 'Watch', 'Lead', 'Corrupted', 'Custom'], "Core");
    createSetting('HeliumHourChallenge', '传送后挑战', '当你使用 氦/小时 或是定制传送时，自动开始这个挑战。 定制传送会在打完指定区域后传送。', 'dropdown', 'None', ['None', 'Balance', 'Decay', 'Electricity', 'Life', 'Crushed', 'Nom', 'Toxicity', 'Watch', 'Lead', 'Corrupted'], "Core");
    //document.getElementById("HeliumHourChallengeLabel").innerHTML = "Portal Challenge:";    //fit it on 1 line.
    createSetting('CustomAutoPortal', '定制传送', '在清除这一层后自动传送。(例子: 设为200，会在到达201层的时候传送)', 'value', '999', null, "Core");
    createSetting('HeHrDontPortalBefore', '不传送直到层数', '在到达这个层数前，禁止氦/小时模式自动传送。 这是一个额外的设置，防止氦/小时的降低触发自动传送。 设为0或-1完全禁止这个设置。 (禁止后传送与否只取决于氦/小时的设置)', 'value', '999', null, "Core");
    createSetting('HeliumHrBuffer', '氦/小时传送缓冲 %', '重要的设置。 当使用氦/小时模式时，当你的氦/小时比本轮最高值降低了最高值的百分之多少时，会自动传送。在0%时关闭  (举例: 值设为5时，会在你本轮最高值的95%时传送)。 现在有了卡关保护 - 如果降低值超过了缓冲百分比的5倍，便能够在层中传送(原先只能在每层第一格传送)(举例:设置2%的缓冲区，如果降低值超过10%则会在层中自动传送)。', 'value', '0', null, 'Core');
    createSetting('PauseScript', '暂停自动脆皮脚本', '暂停自动脆皮脚本(不包括图像模块)', 'boolean', null, null, 'Core');
    //code to locate the pause button at lower right
    var $pauseScript = document.getElementById('PauseScript');
    $pauseScript.parentNode.style.setProperty('float','right');
    $pauseScript.parentNode.style.setProperty('margin-right','1vw');
    $pauseScript.parentNode.style.setProperty('margin-left','0');




//Buildings
    createSetting('BuyBuildingsNew', ['什么都不买','购买建筑&仓库', '购买建筑', '购买仓库'], '当仓库快满时自动购买仓库 (甚至能预料到Jestimp)以及非存储的建筑 (只要能买就买)。在购买非存储建筑之前考虑成本效率。', 'multitoggle', 1, null, "Buildings"); //This should replace the two below
    createSetting('WarpstationCap', '经纱站上限', '在超过基础经纱站+增量千兆站后不再升级经纱站。**. 如果关闭该功能，当不买千兆站时，经纱站也会无限制地升级(浪费了本应花费在升级装备上的金属。) **当每次购买一个新的千兆站时，脚本会绕过这个上限，能买多少经纱站就买多少。(由于自动脚本使可用的金属/宝石一直处于一个较低值，一瞬间内在可承受范围内忽视上限多买一些也不是什么坏事。). ', 'boolean', true, null, 'Buildings');
    createSetting('WarpstationCoordBuy', '购买经纱站以冲击协作', '如果我们距离购买下一个协作非常近了，而且能买得起下一个经纱站，那么就买它！(即使超过了经纱站上限/限制). 建议和 经纱站上限/经纱站限制 配合使用。 (否则便没有意义) ', 'boolean', true, null, 'Buildings'); //Can this just be removed? if it happens, its a good thing.
    createSetting('MaxHut', '茅舍上限', '茅舍', 'value', '100', null, "Buildings");
    createSetting('MaxHouse', '房子上限', '房子', 'value', '100', null, "Buildings");
    createSetting('MaxMansion', '大厦上限', '大厦', 'value', '100', null, "Buildings");
    createSetting('MaxHotel', '旅馆上限', '旅馆', 'value', '100', null, "Buildings");
    //Line2
    createSetting('MaxResort', '娱乐场上限', '娱乐场', 'value', '100', null, "Buildings");
    createSetting('MaxGateway', '出入口上限', '警告: 不建议设置到25以上', 'value', '25', null, "Buildings");
    createSetting('MaxWormhole', '虫洞上限', '警告: 虫洞消耗氦! Values below 0 do nothing.', 'value', '0', null, "Buildings");
    createSetting('MaxCollector', '集电极上限', '建议值: -1', 'value', '-1', null, "Buildings");
    createSetting('MaxGym', '健身房上限', '进阶选项. 建议值: -1', 'value', '-1', null, "Buildings"); //Remove?
    createSetting('MaxTribute', '贡品上限', '进阶选项. 建议值: -1 ', 'value', '-1', null, "Buildings"); //Remove? (More gems is never a bad thing...)
    createSetting('GymWall', '健身房限制', '为了保存木头。只有当你能买得起<b>X</b>个健身房时(所有的价格都相等，均是第一个的价格)，只买一个健身房。 -1 或 0 来关闭该设置。 换句话说，该设置允许健身房花费的木头不超过你所拥有木头的 1/x 。(用来保存木头给托儿所，以达成230层以后的岩浆托儿所策略( new z230+ Magma nursery strategy)).支持输入小数。 (和经纱站限制机制相同，这也是为什么它们名字相似)。设置为1，除了防止一次购买两个健身房外，什么都不做。', 'value', -1, null, 'Buildings'); //remove?
    //Line3
    createSetting('FirstGigastation', '首个千兆站', '在购买第一个千兆站前购买多少个经纱站', 'value', '20', null, "Buildings");
    createSetting('DeltaGigastation', '增量千兆站', '每拥有一个千兆站买多少额外的经纱站。支持填写小数。比如填写2.5，接下来几次就会买2个/3个2个/3个...', 'value', '2', null, "Buildings");
    createSetting('WarpstationWall3', '经纱站限制', '为了保存金属. 只有当你能买得起<b>X</b>个经纱站时(所有的价格都相等，均是第一个的价格)，只买一个经纱站。 -1 或 0 来关闭该设置。 换句话说，该设置允许经纱站花费的金属不超过你所拥有金属的 1/x 。 (用来保存金属用于装备升级)', 'value', -1, null, 'Buildings');
    createSetting('MaxNursery', '托儿所上限', '进阶选项。 建议值: 直到你遇到岩浆(230+层)以前建议-1', 'value', '-1', null, "Buildings");
    createSetting('NoNurseriesUntil', '不造托儿所直到层数', '本设置为了230层后的岩浆惩罚效果(每层按比例摧毁托儿所)。 停止建造托儿所，在前期建造托儿所是一种浪费。可能会想要设置在230以上。 可以和上一个设置：托儿所上限 配合使用。', 'value', -1, null, 'Buildings');
    createSetting('PreSpireNurseries', '尖塔前托儿所', '为了尖塔，设置一个托儿所的制造上限。本设置优先于“不建造托儿所直到层数”和“托儿所上限”设置，所以你可以分开考虑这两类设置！将会在200层前为尖塔1建造一些托儿所。但之后只在尖塔2+的层数建造，为了避免岩浆不必要的摧毁。设置为-1来关闭该选项。', 'value', -1, null, 'Buildings');




//Jobs
    createSetting('BuyJobs', '分配工作', '按照下面的比例配置来分配工作。注意:打开该功能后你将无法手动分配工作。如果你需要手动操作，关闭该选项。', 'boolean', true, null, "Jobs");
    createSetting('WorkerRatios', '自动工人比例', '根据当前进度自动改变工人比例。 警告:该设置优先于后面的工人比例设置。 设置方案: 1/1/1 直到300k 脆皮, 3/3/5 直到 3M 脆皮, 之后当超过3M脆皮时为 3/1/4 , 之后当贡品超过1000时为 1/1/10 , 之后当贡品超过1500时为 1/2/22 , 之后当贡品超过3000时为 1/12/12 ', 'boolean', true, null, "Jobs");
    createSetting('AutoMagmamancers', '自动巫师', '自动管理巫师。当你在当前区域停留时间超过10分钟时，雇佣巫师。一次性花费最多10%你拥有的的宝石。之后每在这层增加10分钟，就重复花10%宝石的雇佣过程。当你拥有巫师的专精时，每5分钟雇佣它们一次。声明：可能对宝石的数目有不良影响。', 'boolean', true, null, 'Jobs');
    createSetting('FarmerRatio', '农民比例', '', 'value', '1', null, "Jobs"); //realistically gems are not that useful by the time you have magmamancers... maybe just set it to only spend 50% of your gems at a time and leave it at that? 10% is kinda low anyway
    createSetting('LumberjackRatio', '伐木工比例', '', 'value', '1', null, "Jobs");
    createSetting('MinerRatio', '矿工比例', '', 'value', '1', null, "Jobs");
    //createSetting('ScientistRatio', 'Scientist Ratio', 'Advanced. This will allow you to cap your scientist to worker ratio, as well as disable the hiring of scientists. <br><b>-1</b> Allows the ratio to be set automatically (Recommended)<br><b>0 </b> Turns off Scientist hiring<br><b>\>0</b> Set a custom ratio.', 'value', '-1', null, "Jobs");
    createSetting('MaxScientists', '科学家上限', '进阶选项.你的科学家的数量上限 (这是一个数而不是比值)。 建议值: -1 (它是无上限的，但它仍旧控制着数量。)', 'value', '-1', null, "Jobs");
    //Line2
    createSetting('MaxExplorers', '探险者上限', '进阶选项. 你的探险者的数量上限(这是一个数而不是比值)。 建议值: -1', 'value', '-1', null, "Jobs"); //Explorers are important now! outdated setting tbh
    createSetting('MaxTrainers', '培训师上限', '进阶选项. 你的培训师的数量上限(这是一个数而不是比值)。 建议值: -1', 'value', '-1', null, "Jobs"); //by the time that you stop needing block, food is abundant
    createSetting('TrainerCaptoTributes', '培训师限制 %', '只有当 购买培训师消耗的食物 小于 购买贡品的食物的x%时 才购买培训师。本设置可以和上一个设置结合使用，或者也可以将上一个设置为-1，让本设置完全掌控。 默认值: -1 (关闭). 当设置为50%时该设置基本不起什么作用了。你可以按着你的想法往低设置，但是建议在10%到1%之间。 (例子: 培训师消耗5001食物，贡品消耗100000食物，设定值为5，这个时候就不会购买培训师。)', 'value', '-1', null, 'Jobs'); //this is a bit unnecessary, resource management by the script is already sufficient.




//GEAR:
    createSetting('BuyArmorNew', ['护甲:什么都不买','护甲:两种都买', '护甲:锻造新护甲', '护甲:购买升级'], '自动锻造或是升级性价比最高的护甲。健身学的购买也受本设置购买重铸选项的控制。', 'multitoggle', 1, null, "Gear"); //This should replace the two below
    createSetting('BuyWeaponsNew', ['武器: 什么都不买','武器:两种都买', '武器: 锻造新武器', '武器: 购买升级'], '自动锻造或是升级性价比最高的武器', 'multitoggle', 1, null, "Gear"); //This should replace the two below
    createSetting('CapEquip2', '装备最大等级', '装备等级达到这个数字后便不再升级。在脚本把装备升级到较高的等级时，本设置能停止金属不必要的消耗，只在到达该等级后重铸装备。 建议值: 早期游戏中设为 10, 后期游戏中设为: 100。设为-1或0来关闭该功能。<b>NEW:</b> Also sub-caps to 10% of your number during liquified or overkilled(under 25sec) zones. This does not mean the script always hits the cap. Your Equip will now always be leveled to at least 2 since its the most effective level. It will only be leveled however if you dont have enoughHealth or enoughDamage. But During Spire, everything will be leveled up to the cap.<br><b>Hidden var: </b>MODULES[\\"equipment\\"].capDivisor = 10; //number to divide your normal cap by.', 'value', 10, null, 'Gear');
    createSetting('DynamicPrestige2', '动态获取锻造书 层数', '动态获取锻造书: <b>设定一个目标层数: Z #. (设为0或-1关闭该设置)</b><br> 起初跳过因获取锻造书而刷地图的过程，然后逐渐地获取你在锻造书中所设置的需要的锻造书(在\'锻造书\'选项中设置，当达到本设置中设置的目标层数后，刷哪些武器的锻造书)。开始时选为匕首，在我们需要更好的装备前能省下大量的时间，然后在本轮末期开始增加锻造书的获取。检测你拥有哪些锻造书，你需要获取多少错过的才能达成你需要的目标，以及在每个区域运行地图(更高的锻造书设置会运行更多地图)，直到达到所设置的锻造书。<br><br>译者：原文由于同义词、表述不够明确等原因，难以理解其中内涵，苦思1小时也无太大进展，只好通过测试来了解。测试结果：相当于在到达你所设置的层数前，将\'锻造书\'设置为攻击匕首，即只有当盾和匕首锻造书在地图上可获得时才主动进入地图获取锻造书。在接近所设区域时，会逐渐刷地图，最后到达所设区域时，获取完\'锻造书\'中所设置的所有锻造书。建议将值设为只升匕首就能秒怪的区域数。', 'value', -1, null, 'Gear');
    createSetting('Prestige', '锻造书', '当所选中的(及以上的)锻造书可以在地图上获得时，去地图上获得它们。强制装备优先模式(只获取选中及以上的锻造书)。自动地图必须开启。这项设置非常重要，与快速爬层有关，且应当一直选着某个选项。如果你发现使用脚本在哪个地方卡住了，尤其是在你本来很轻松就能通过的地方，就将其设置为列表中更下面的选项，这会保证你推层中变得更强力，但是会花费更多时间在地图上打锻造书。', 'dropdown', 'Polierarm', ['Off', 'Supershield', 'Dagadder', 'Bootboost', 'Megamace', 'Hellishmet', 'Polierarm', 'Pantastic', 'Axeidic', 'Smoldershoulder', 'Greatersword', 'Bestplate', 'Harmbalest', 'GambesOP'], "Gear");
    //Make a backup of the prestige setting: backup setting grabs the actual value of the primary setting any time it is changed, (line 784 of the function settingChanged())
    var lastSetting = autoTrimpSettings["PrestigeBackup"];
    autoTrimpSettings["PrestigeBackup"] = {
        selected: (lastSetting != undefined ? lastSetting.selected : autoTrimpSettings["Prestige"].selected ) || "Off",
        id: "PrestigeBackup",
        name: "PrestigeBackup"
    };
    //Line2:
    createSetting('ForcePresZ', '强制获取锻造书层数', '一旦到达该层数，或是超过该层数，只要有锻造书可获取，就立即去获取，忽略“动态获取锻造书”设置，并且优先于\'锻造书\'选项。 跳过锻造书模式将退出该设置。设为-1禁用。', 'value', -1, null, 'Gear');
    createSetting('PrestigeSkip1_2', ['跳过锻造书 关闭','跳过锻造书 1 & 2', '跳过锻造书 1', '跳过锻造书 2'], '<b>跳过锻造书 1:</b>如果你拥有2个以上的未购买进阶项(不包括盾牌), ie: 位于你的升级栏内但你买不起它们，自动地图将不会进入\'锻造书\'模式，以及/或从该模式中离开。未购买进阶的数量可以通过这项可变的模块来设置 MODULES[\\"maps\\"].SkipNumUnboughtPrestiges = 2; <br><b>跳过锻造书 2:</如果在地图上有少于2个的<b>未获取武器锻造书</b>,ie:如果有少于2种在地图上，自动地图将不会进入锻造书模式，以及/或从该模式中离开。本设置适用于一些由于资源获取不足，倾向于不需要最后几种锻造书的玩家。未获取锻造书的数量可以通过这个来设置 MODULES.maps.UnearnedPrestigesRequired.如果跳过锻造书1&2模式启用, 两个条件都达到后才会退出锻造书模式。', 'multitoggle', 0, null, "Gear");
    createSetting('DelayArmorWhenNeeded', '延迟护甲进阶', '当你处于\'需要更多伤害\'或\'挂机\'自动地图模式时，延迟购买护甲进阶，但如果你处于\'需要生命和伤害\'模式，它就会购买进阶。提示：<b>只适用于进阶</b>', 'boolean', false, null, 'Gear');
    createSetting('BuyShieldblock', '购买盾牌防御', '将会购买 盾牌防御 升级。注意:如果你层数高于60,你可能不会想要这个升级。 :)', 'boolean', false, null, "Gear");




//AutoMaps + VoidMaps settings:
    createSetting('AutoMaps', ["自动地图关闭","自动地图开启","自动地图(非特殊)"], '推荐。 自动运行地图来发展。 非常重要。有多种模式： <b>锻造书, 虚空, 需要更多伤害, 需要更多生命, 需要更多生命 & 伤害, 以及 挂机.</b>在锻造书模式下会制作一个与当前区域相同等级的地图并战斗，直到拿到在 锻造书 列表设置中所设置的东西。虚空模式非常明显：使用虚空难度检测设置来控制挂机的量。如果是‘需要更多伤害’模式,就会打10遍地图以获取200%的地图伤害加成。如果是‘挂机’模式，就会在生命伤害比>16x的时候一直刷地图。 \'需要更多生命[或伤害]\' 模式基本就是一个状态信息，告诉你需要更多的生命值了。除了让 自动升级装备 的脚本去继续升级物品以外，就没什么可做的了。如果你处于 \'需要生命值\'模式，但如果继续下去你的伤害还不错，在有关生命值的能力上投入更多。<hr>特殊地图可以自动运行，除非禁用该功能。<br><b>自动运行 高墙 以及 愤怒维度 需要特殊模式.</b> 以下挑战为了完成自动传送也需要开启特殊模式：电流, 地图的启示, 冥想, 以及粉碎(等等) 。 <p> 地图/等级: <br>障碍区 - 12<br>高墙 - 16<br>愤怒维度 - 21<br>末日之神殿 - 34<br>监狱 - 82<br>仿生仙境 (只在粉碎挑战下) @ 127<br><b>补充:</b> 这个功能正常情况下应当开启。<br><B>补充:</B> Run Bionic Before Spire prevents the setting of Unique. <br><b>注意:</b> This does <b>NOT</b> auto-run all your Bionics according to your lack of Robotrimp status or whether you pass a certain level (yet).', 'multitoggle', 1, null, "Maps");
    createSetting('DynamicSiphonology', '动态虹吸学', '建议一直开启. 根据你的输出伤害来使用恰当的虹吸学等级。 例子: 只在你较弱(相对于怪)的时候使用虹吸学。把本设置关闭意味着使用虹吸学永远在使用范围内最低的地图级别。 虹吸学是你在115~125区域左右得到的一种能力，能够让你在运行较低等级的地图中获得的叠加伤害加成在本区域中使用 - 最多是低3层(每级1层).', 'boolean', true, null, 'Maps'); //Should always be on?
    createSetting('PreferMetal', '更多金属地图', '总是倾向于金属地图，常手动操作时使用，比如尖塔前的挂机模式。记住，当挂机模式结束后把它关闭！', 'boolean', false, null, 'Maps'); //rarely better tbh
    createSetting('MaxMapBonusAfterZone', '最大地图加成层数', '从这一区域开始总是刷满最大地图加成。 (包括这个区域以及后面的区域)。<br><b>补充:</b> 设为 -1 来关闭(禁用). 设为 0 来保持永久开启。<br><b>进阶:</b>User can set a lower number than the default 10 maps with the AT hidden console command: MODULES[\\"maps\\"].maxMapBonusAfterZ = 9;', 'value', '-1', null, 'Maps');
    createSetting('DisableFarm', '禁用挂机', '禁用了脚本自动地图部分延伸出的挂机算法。一旦地图加成叠到10层后直接返回世界。风险自负。 (No need to refresh anymore)', 'boolean', false, null, 'Maps');
    createSetting('LowerFarmingZone', '更低的挂机区域', '降低在挂机模式中刷地图的级别。使用动态虹吸学的代码，找到一个你能成功一次通过(successfully one-shot)的地图中，最高的地图级别，并在10层地图加成后，使用这个级别的任何一张地图。不同之处在于，本设置选择的地图等级比虹吸学能起作用的等级还要低。虹吸学让你能叠地图加成，但是叠满10层后你就不需要再叠加成了，你只是需要一张你能一次通过的地图去刷资源。如果你的伤害实在很低，选择的地图比你现在的区域低10层，这实在是一个信号，告诉你，你该传送了。T', 'boolean', true, null, 'Maps');
    createSetting('FarmWhenNomStacks7', '美味效果>7时挂机', '可选的. 如果无序已经拥有5层美味效果，就叠30层预期效果。如果无序的美味效果>7,去地图刷+200%的伤害加成。如果还是无法打败它，在30层时进入挂机模式， Even with DisableFarming On! (exits when we get under 10x). Farms if we hit 100 stacks in the world. If we ever hit (100) nomstacks in a map (likely a voidmap), farm, (exit the voidmap) and (prevent void from running, until situation is clear). Restarts any voidmaps if we hit 100 stacks. ', 'boolean', false, null, 'Maps');

    //Line2
    createSetting('MaxStacksForSpire', '为尖塔，地图加成最大化', '在运行尖塔前刷满地图加成。', 'boolean', false, null, 'Maps'); //Does farm before spire not cover this fairly well anyway? grabbing +1 equips would make way more difference anyway
    createSetting('MinutestoFarmBeforeSpire', '尖塔前挂机', '在进入尖塔前去200/199(或者 BW)级的地图挂机X(你所设置)分钟<br><b>补充:</b> 设为0完全关闭(禁用). <br>设为-1/无限在这里是没有用的,要设置一个很高的数值才行。', 'value', '0', null, 'Maps');
    createSetting('IgnoreSpiresUntil', '忽略尖塔直到', '专门为尖塔而设的设置，在到达这一层前，忽略尖塔。(设为0来关闭)<br>Does not work with Run Bionic Before Spire.', 'value', '200', null, 'Maps');
    createSetting('RunBionicBeforeSpire', 'Run Bionic Before Spire', '注意:  Runs Bionic Wonderlands and repeatedly farms Bionic VI @ level 200 before attempting Spire, for the purpose of resource farming. Then it attempts the spire. The Minutes-Before-Spire timer runs concurrently to this, and <b>needs</b> to be set. If not set, it will exit without doing any Bionics... You can un-toggle it on the fly. <br><b>NOTE:</b> Turning this on also mandates that Run Unique Maps be on. <br><b>WARNING:</b> These 100 square maps take ~3x longer than normal maps. <br><b>WARNING:</b> If you dont have Bionic Magnet mastery, this will run the 5 pre-requisites and take longer.<br><b>NOTE:</b> In fact, it may not be what you want at all.', 'boolean', false, null, 'Maps'); //OUTDATED!
    createSetting('ExitSpireCell', '离开尖塔在房间：', '可选的/特殊的. 当你打通房间x的时候，提前离开尖塔。 例子: 设为40就会在地图上打完4行。 (设为0或-1禁用)', 'value', '-1', null, 'Maps');
    createSetting('CorruptionCalc', '腐化挂机模式', '推荐。开启这项功能将会使自动地图程序把一个区域中的腐化量考虑在内，来决定是先刷地图拿资源还是先拿地图加成。只在181区域以上有效（或是Headstart 1,2,3 zone: 176,166,151) ', 'boolean', true, null, 'Maps');
    createSetting('MaxTox', '最大毒性层数', '毒性挑战时，在区域60以后，杀死无序前先叠够最大层的毒性效果。一般只推荐这样打一次，来获得最大单轮氦获得，买骨头传送门时能获得更多氦。本选项将在成功最大毒性运行+毒性自动传送后切换为禁用。', 'boolean', false, null, 'Maps');

    //Line3
    createSetting('VoidMaps', '虚空地图区域', '<b>设为0禁用</b> 设定一个区域，在这个区域中把你所有的虚空地图都打通。 默认情况下在第93个房间运行它们，除非你输入一个小数来选择特定的房间(例子: 187.75). Use odd zones on Lead.', 'value', '0', null, "Maps");
    createSetting('RunNewVoidsUntilNew', '新虚空地图', '<b>设为0禁用。设为正数就加在你所设的虚空地图区域上。设为-1为没有上限。</b> 这项设置允许你运行在虚空地图区域后得到的新虚空地图，通过在虚空地图区域上加一个数。<br> <b>例子</b> 虚空地图区域=185.75 并且本设置=10。 在197.75前得到的新虚空地图将会运行)。<br>这意味着在区域197的75房间前得到的任何虚空地图将会运行。注意：尝试运行级别太高的虚空地图可能会严重拖慢你。设为0禁用 (关闭)。', 'value', '0', null, 'Maps'); //Should replace the two below
    //createSetting('VoidsPerZone', 'Voids per Zone', 'Run a max of this many Voids per zone, if you have a lot of Voids saved up. Then moves onto the next zone and does more voids.', 'value', '-1', null, 'Maps');
    createSetting('VoidCheck', '虚空难度检测', '在你试图打这个虚空地图之前，在X姿态下你能承受虚空地图boss几下攻击。更高的数值会使你在打虚空地图时更强(通过挂机地图获得生命)H。设置为0或-1关闭这个设置，并默认为在2次攻击中存活。我建议设置为2与12之间的一个数(现在的默认值是6) 。', 'value', '6', null, 'Maps');
    createSetting('TrimpleZ', '打Trimple 层数', '我认为自动做这个不是个好主意。你可能在此之前想多挂一会机，但是我不确定如果设置一个“在打trimple前挂机X分钟”的参数是否有意义。设置为一个你想要的层数，它会在获取地图加成以及挂机后运行Trimple of Doom来获得Ancient Treasure。如果设置一个负数，则在成功运行后将被禁用，因此你下次可以将其设置为不同的值。', 'valueNegative', 0, null, 'Maps'); //in reality this needs another setting to make it farm for a set number of minutes without spending anything. And I cba cause its a meh setting anyway. Advancing 2 zones more than doubles your income. Only useful for spire I, and IMO you may aswell actually play the game manually at SOME point.
    createSetting('AdvMapSpecialModifier', 'Map Special Modifier', '<b>实验性的。</b> Attempt to select the BEST map special attacks mod. With this on, this will replace the normal behavior. If bugs, please report as this will become more default soon.', 'boolean', false, null, 'Maps');




//Combat
    //Subsection1Line1
    createSetting('BetterAutoFight', ['更好的自动战斗 关闭', '更好的自动战斗 1', '更好的自动战斗 2',], '3种模式的按钮， 推荐。 将自动处理战斗。选择1模式还是2模式取决于你的判断。新的2模式会做: A)Click fight anyway if we are dead and stuck in a loop due to Dimensional Generator and we can get away with adding time to it.(RemainingTime + ArmyAdd.Time &lt; GeneTimer) and B) Clicks fight anyway if we are dead and have &gt;=31 NextGroupTimer and deal with the consequences by firing genetecists afterwards. 警告: 如果你使用自动传送，并禁用更好的自动战斗，直到你点击“战斗”前游戏会停滞，什么都不做。 (在afk模式下非常不好) ', 'multitoggle', 1, null, "Combat");
    createSetting('AutoStance', ['自动阵型 关闭', '自动阵型 1', '自动阵型 2', '自动阵型 3'], '自动切换阵型来避免死亡。使用模式1还是模式2取决于你的判断，它们应当是相似的。更好的自动战斗(我觉得原文打错，应该是阵型)3是一个新的，实验性的功能，用于遇到自然(区域230)后，会让你一直处于D阵型 unless you are windstacking (only useful if transfer is maxed out and wind empowerment is high. 该功能目前只是根据请求添加的一个调整。', 'multitoggle', 1, null, "Combat");
    createSetting('WindStackingMin', 'Windstack Min Zone', '<b>-1 = 关闭<br>0 = 总是开启</b><br>For use with AutoStance 3, enables windstacking in zones above and inclusive of the zone set. (Get 200 windstacks then change to D, kill bad guy, then repeat). This is designed to force S use until you have 200 stacks in wind zones, overriding scryer settings.', 'value', '-1', null, 'Combat');
    createSetting('IgnoreCrits', ['安全第一', '忽略虚空力量', '忽略所有重击'], '不再切换到B阵型来抵抗腐化精准以及/或是虚空力量。 <b>基本我们在自动阵型1以及自动阵型2中将“暴击”当做常规的事物</b>。事实上它们不将敌人的 力量/精度 等状态计算在内，就将他们当做普通的敌人，来根据你的需要选择X/D阵型。如果你打一个重击日常的一个重击敌人，你确定你的防御足够高，就使用本选项！或者，你可以自己管理你的阵型。', 'multitoggle', 0, null, 'Combat');
    createSetting('PowerSaving', ['Don\'t care', 'Power Saving', 'Only Rush Voids'], 'Avoid killing your army impatiently. Don\'t force abandon trimps when prestiging. Will still Die To Use Z and aggressively autostance to aid progression and anything else. Made for Empower daily, you might find it helpful if you\'re doing Workplace Safety feat. Then again with that I strongly recommend doing it fully manually. Anyway, don\'t blame me whatever happens. Only Rush Voids will allow considering abandoning, not force one. <b>Note:</b> AT will no longer be able to fix when your scryer gets stuck!', 'multitoggle', 0, null, 'Combat');
    createSetting('ForceAbandon', 'Auto Force-Abandon', '(Trimpicide). If a new fight group is available and anticipation stacks arent maxed, force abandon and grab a new group. Located in the geneticist management script.', 'boolean', true, null, 'Combat');
    createSetting('DynamicGyms', '动态健身房', '设计来限制你的防御，无论敌人攻击有多少，只让防御比敌人攻击高一点点。如果“健身房上限”设定了上限，且设置了“健身房限制”，这两样仍然有效，本项设置不会优先于那两项(它们同时运行)，但是本设置会进一步限制它们。在未来可能会让本设置优先于那两项，但是这种计算不容易弄合适，所以在我做完其他事前不想进行这项工作。', 'boolean', false, null, 'Combat'); //Does anybody actually use this?
    createSetting('AutoRoboTrimp', '自动机械脆皮', '从这一区域开始使用机械脆皮的能力，之后每5层再次使用。(设为0禁用，默认值60。) 60对于大多数玩家来说是一个很好的选择。', 'value', '60', null, 'Combat');




//Scryer
    createSetting('UseScryerStance', '允许占卜者阵型', '<b>主要按钮</b> 本按钮决定是否启用其他的占卜者设置，且在达到开启占卜者阵型的条件时，会优先于自动姿态，直接开启占卜者阵型。当本设置开启时需要开启自动阵型。占卜者阵型会给你2倍的掠夺资源（不包括氦），以及有概率获得黑暗精华(区域180以上)。当本设置开启时，占卜者阵型的优先级决定如下:<br>永不使用, 强制使用, 超杀时使用, 最小/最大区域<br><br><b>当本设置关闭时其他本类设置也无法起作用。</b>', 'boolean', true, null, 'Scryer');
    createSetting('ScryerUseWhenOverkill', '超杀时使用', '优先于最小/最大区域选项。不优先于所有“永不”选项。在使用S阵型时能够秒杀敌人时使用S阵型，在没有速度影响的情况下给我们二倍的掠夺战利品！ <b>注意:</b> This being on, and being able to overkill in S will override ALL other settings <u>(Except never use in spire)</u>. This is a boolean logic shortcut that disregards all the other settings including Min and Max Zone. If you ONLY want to use S during Overkill, as a workaround: turn this on and Min zone: to 9999 and everything else off(red). <br><br>This has not been optimised for double overkill, and does not always produce the intended results, if you have problems, it may be worth turning off until it can be adjusted.', 'boolean', true, null, 'Scryer');
    createSetting('ScryerMinZone', '最小区域', 'Minimum zone to start using scryer in.(inclusive) Recommend:(60 or 181). Overkill ignores this. This needs to be On & Valid for the <i>MAYBE</i> option on all other Scryer settings to do anything if Overkill is off. Tip: Use 9999 to disable all Non-Overkill, Non-Force, scryer usage.', 'value', '181', null, 'Scryer');
    createSetting('ScryerMaxZone', '最大区域', '<b>设为0或-1禁用(推荐)</b><br>Overkill ignores this. Zone to STOP using scryer at (not inclusive). Turning this ON with a positive number stops <i>MAYBE</i> use of all other Scryer settings.', 'value', '230', null, 'Scryer');
    createSetting('ScryerUseinMaps2', ['地图: 永不','地图: 强制', '地图: 可能'], '<b>永不</b> 就是标题说的意思!!!<br><b>强制</b> 在虚空地图中永远启用占卜者阵型<br><b>可能</b> means that Overkill and Min/Max use are allowed.<br>This setting requires use on Corrupteds to be on after corruption/magma.<br><br>Recommend MAYBE.', 'multitoggle', 2, null, 'Scryer');
    createSetting('ScryerUseinVoidMaps2', ['虚空地图: 永不','虚空地图: 强制', '虚空地图: 可能'], '<b>NEVER</b> means what it says!!!<br><b>FORCE</b> means Scryer will ALWAYS activate in Void Maps<br><b>MAYBE</b> means that Overkill and Min/Max use are allowed.<br>This setting requires use in Maps to be on, as well as use on Corrupteds (if above corruption/magma) to activate.<br><br>Recommend NEVER.', 'multitoggle', 0, null, 'Scryer');
    createSetting('ScryerUseinSpire2', ['尖塔: 永不','尖塔: 强制','尖塔: 可能'], '<b>NEVER</b> means what it says!!!<br><b>FORCE</b> means Scryer will ALWAYS activate in the Spire<br><b>MAYBE</b> means that Overkill and Min/Max use are allowed.<br>This setting requires use on Corrupteds to be on for corrupted enemies.<br><br>Recommend NEVER.', 'multitoggle', 0, null, 'Scryer');
    //Line2
    createSetting('ScryerSkipBoss2', ['Boss: 永不 (所有区域)','Boss: 永不 (Above VoidLevel)','Boss: 可能'], '<b>永不 (所有区域)</b> 将在世界的第100房间不使用S阵型!!!<br><b>NEVER (Above VoidLevel)</b> will NEVER use S in cell 100 of the world ABOVE the zone that your void maps are set to run at (Maps).<br><b>MAYBE</b> treats the cell no differently to any other, Overkill and Min/Max Scryer is allowed.<br><br>Recommend NEVER (There is little benefit to double NON-HELIUM resources and a small chance of DE).', 'multitoggle', 0, null, 'Scryer');
    createSetting('ScryerSkipCorrupteds2', ['Corrupted: NEVER', 'Corrupted: FORCE','Corrupted: MAYBE'], '<b>NEVER</b> means what it says!!!<br><b>FORCE</b> means Scryer will ALWAYS activate against Corrupted enemies<br><b>MAYBE</b> means that Overkill and Min/Max use are allowed.<br><b>Magma maps and Corrupted Voidmaps are currently classified as corrupted</b> and NEVER here will override Maps and Voidmaps use of Scryer<br><br>Recommend MAYBE.', 'multitoggle', 2, null, 'Scryer');
    createSetting('ScryerDieZ', 'Die To Use S','<b>-1 to disable.</b><br>Turning this on will switch you back to S even when doing so would kill you. Happens in scenarios where you used Skip Corrupteds that took you into regular Autostance X/H stance, killed the corrupted and reached a non-corrupted enemy that you wish to use S on, but you havent bred yet and you are too low on health to just switch back to S. So you\'d rather die, wait to breed, then use S for the full non-corrupted enemy, to maximize DE. NOTE: Use at your own risk.<br>Use this input to set the minimum zone that scryer activates in (You can use decimal values to specify what cell this setting starts from)' , 'value', 230.60, null, 'Scryer');
    createSetting('ScryUseinPoison', 'Scry in Poison','<b>-1 to disable</b>, any other number (including 0) sets a minimum zone to use S in Poison', 'value', -1, null, 'Scryer');
    createSetting('ScryUseinWind', 'Scry in Wind','<b>-1 to disable</b>, any other number (including 0) sets a minimum zone to use S in Wind', 'value', -1, null, 'Scryer');
    createSetting('ScryUseinIce', 'Scry in Ice','<b>-1 to disable</b>, any other number (including 0) sets a minimum zone to use S in Ice', 'value', -1, null, 'Scryer');



// Dimensional Generator settings:
    createSetting('UseAutoGen', ['自动维度发生器 关闭', '自动维度发生器 开启'], '<b>主要按钮</b> 动态切换维度发生器的模式。下面几种设置需要本设置开启才能使用。维度发生器是在230区域的岩浆中才能解锁的一种建筑。', 'multitoggle', 0, null, 'Magma');
    createSetting('AutoGen2', ['禁用', '满足单次', '最大上限', '超频'], '在达到Z区域之前，满足单次和最大上限将在[混合 / 获得燃料]间切换，在使用[获得岩浆岩]模式前，来保持能满足恰好一次 / 满容量 (不是存储)。设为禁用将一直遵守你所设置的，除非挑战优先级开启，否则不会改变。超频模式将一直获取燃料直到Z区域。', 'multitoggle', 2, null, 'Magma');
    createSetting('AutoGen2End', '结束早期模式：Z区域', '在Z区域及以后,结束最开始设置的模式，并转换为最终模式。设为-1禁用。', 'value', 300, null, 'Magma');
    createSetting('AutoGen2SupplyEnd', 'End at Supply', 'On and after the zone for gathering the most magma by Supply, end Early Mode. Works alongside AutoGen2End and will end when either condition is met.', 'boolean', false, null, 'Magma');
    createSetting('AutoGen3', ['①获取岩浆岩', '①获取燃料', '①混合'], '在Z区域/SupplyEnd 后使用的最终模式。', 'multitoggle', 1, null, 'Magma');
    createSetting('AutoGenDC', ['日常: 正常', '日常: 燃料', '日常: 混合'], '在日常挑战中使用一种特定的模式。除非强制优先级开启，否则本设置优先于①选项。', 'multitoggle', 1, null, 'Magma');
    createSetting('AutoGenC2', ['挑战2: 正常', '挑战2: 燃料', '挑战2: 混合'], '在挑战2中使用一种特定的模式。除非强制优先级开启，否则本设置优先于①选项。', 'multitoggle', 1, null, 'Magma');
    createSetting('AutoGen2Override', ['Override Final Only', 'Strong Override'], 'Overrides apply to the final mode (always use early mode), or also to early mode (will stop microtick etc). Normal will not change anything.', 'multitoggle', 1, null, 'Magma');
    createSetting('AutoMagmiteSpender2', ['花费岩浆岩 关闭', '花费岩浆岩 (传送)', '花费岩浆岩 总是'], '在传送前立即花费岩浆岩升级。 (或总是升级, 如果选为总是)。第一步：先购买永久的、一次性的升级，按从贵到便宜的顺序。第二步：分析效率和容量的效益/花费，如果购买效率比购买容量更好，则购买效率。如果购买效率并非更好，在此基础上容量的价格比供给的价格低，就购买容量。如果供给价格低，就购买供给。不断重复以上步骤，直到花光岩浆岩，无法购买任何升级。此选项为230区域以上的岩浆区设置。', 'multitoggle', 1, null, 'Magma');
    createSetting('SupplyWall', '供给抑制(或是容量)', '设为不为1的正数。举例. 2.5: 当供给的价格*2.5 < 容量价格时，升级供给, 而不是当能买时则购买。 当你不需要太多供给时有效抑制它的花费。<br><br>设为负数 (可以设为-1) 举例. -2.5: 当供给的价格 < 容量价格*2.5时，升级供给！有效抑制容量花费。<br><br><b>设为1: 不升级供给，只将岩浆岩消耗在效率、容量以及超频上。 (对于一些后期玩家来说，升级供给可能是没有价值的。)<br>设为0: 忽视该设置，并使用旧设置(将仍然尝试购买超频)</b>', 'valueNegative', 2, null, 'Magma');
    createSetting('BuyOneTimeOC', ['只买单次 (无超频)', '可能买单次 & 超频', '可能买单次 (无超频)', '只购买单次 & 超频'], '只买单次(无超频) = 只购买单次升级项,不买其他的。 <br>可能买单次 & 超频 = 正常购买升级, 将考虑购买超频以及单次升级项。<br>可能买单次 (无超频) = 正常购买升级,但是将不考虑购买超频 (如果你没买过超频，将会购买1级)。<br>只购买单次 & 超频 = 将强制花费岩浆岩来升级这两项，忽略效率、容量以及供给。<br> 建议禁用 (即设为可能买单次 & 超频)', 'multitoggle', 1, null, 'Magma');
    createSetting('MagmiteExplain', '岩浆岩花费方式', '1. 优先购买单次升级项中的升级，先买贵的。其次考虑购买第一级的超频;<br>2. 如果能买得起，就购买超频;<br>2.5. 如果设为“只买单次”则退出升级<br>3.如果升级效率比升级容量好，则升级效率;<br>4.购买容量或供给，取决于谁更便宜，或是取决于供给抑制。', 'infoclick', 'MagmiteExplain', null, 'Magma');




//Heirloom Settings
    createSetting('AutoHeirloomsNew', ['自动传家宝 关闭', '自动传家宝 1', '自动传家宝 2'], '自动传家宝 1 = 自动地评估并携带最好的传家宝，并且建议升级所装备的物品。只有当传家宝页面没有打开的时候自动传家宝才能改变所装备的物品。携带的传家宝将会和已装备的传家宝相互比较并进行交换。如果装备栏还是空的，就会把最好的盾装上去(如果有的话)。评估只基于以下的几种方式 (按优先级排序，由高到低): 虚空地图掉落率/脆皮攻击, 暴击率/暴击攻击, 矿工效率/金属掉落, 钻石掉落/Dragimp 效率, 农民/伐木工效率。 出于携带的目的，稀有度胜过所有种类的评估。Empty mod slots are valued at the average value of the best missing mod. <br> 自动传家宝 2 = 对于传家宝的新算法。 注意:开启这个模式将立刻根据新算法重新整理你的传家宝，然后再把它关闭，即使你的传家宝并没有什么变化，它也会恢复到原来的算法。 (供参考: 这种换回来后的不作为凸显出了旧模式的问题。', 'multitoggle', 0, null, 'Heirlooms');
    createSetting('AutoUpgradeHeirlooms', '自动升级传家宝', '自动升级脚本所建议装备的盾牌和人员，直到用光虚空物质。', 'boolean', false, null, 'Heirlooms');



//Golden Upgrade Strategies:
    createSetting('AutoGoldenUpgrades', '自动金色升级', '重要的设置。当有黄金升级时自动购买指定的黄金升级。 <b>NOTE:</b>虚空选项会解锁更多设置：策略、 Void setting unlocks more settings: goldStrat, goldAlternating, goldZone and goldNoBattle. <b>New:</b> Void also has a \\"Max then Helium\\" setting so you can get the perfect 60% Voids then Helium. More buttons will become visible when you make selections.', 'dropdown', 'Void', ["Off", "Helium", "Battle", "Void"], 'Golden');
    createSetting('goldStrat', '策略', 'VOID ONLY: After max Void golden upgrades, alternate between buying helium and battle upgrades. Or Choose a Zone to switch over completely at (zones lower than X will buy only battle, and zones higher than X only helium). Battle can be disabled completely with the goldNoBattle button. <b>最大后升氦 </b> setting so you can get the perfect 60% Voids then Helium', 'dropdown', 'Max then Helium', ["Off", "Alternating", "Zone", "Max then Helium"], 'Golden');
    createSetting('goldAlternating', 'GU VOID: Alternating', 'Buy a helium upgrade after X-1 battle upgrades have been purchased', 'value', '2', null, 'Golden');
    createSetting('goldZone', 'GU VOID: Zone', 'Buy a helium upgrade until zone X, then buy battle upgrades.', 'value', '200', null, 'Golden');
    createSetting('goldNoBattle', 'GU VOID: No Battle', 'Green = Do <b>NOT</b> buy Battle Upgrades <br> Red = Buy Battle Upgrades.', 'boolean', true, null, 'Golden');



// Nature settings:
    createSetting('AutoNatureTokens', '花费自然符记', '<b>主键</b> 自动花费或转换自然符记。', 'boolean', false, null, 'Nature');
    createSetting('AutoPoison', '毒', '花费/转换毒符记', 'dropdown', 'Off', ['Off', 'Empowerment', 'Transfer', 'Convert to Wind', 'Convert to Ice', 'Convert to Both'], 'Nature');
    createSetting('AutoWind', '风', '花费/转换风符记', 'dropdown', 'Off', ['Off', 'Empowerment', 'Transfer', 'Convert to Poison', 'Convert to Ice', 'Convert to Both'], 'Nature');
    createSetting('AutoIce', '冰', '花费/转换冰符记', 'dropdown', 'Off', ['Off', 'Empowerment', 'Transfer', 'Convert to Poison', 'Convert to Wind', 'Convert to Both'], 'Nature');



//Display settings:
    //Subsection1Line1
    createSetting('EnhanceGrids', '加强网格显示', '在世界和地图的网格上启用轻微的视觉增强效果，将所有外来物种，powerful, skeletimps(掉骨怪)以及一些特殊的小怪以高亮阴影显示。', 'boolean', false, null, 'Display');
    createSetting('EnableAFK', '进入AFK(离开)模式', '(功能按钮)。 进入AFK模式会让屏幕变黑，并暂停所有的脆皮图形界面的可视化更新功能(updateLabels)，如此便可减少些不必要的运算来提高电脑性能。这项功能主要用来节省CPU和内存占用。当你点击返回按钮时，一切都会复原。在此状态控制台调试功能也被禁用。本按钮为蓝色，说明这不是用来设置的，只是一个按钮而已。你现在也可以通过点击 区域#(世界信息)部分来进入AFK模式。', 'action', 'MODULES["performance"].EnableAFKMode()', null, 'Display');
    document.getElementById('battleSideTitle').setAttribute('onclick','MODULES["performance"].EnableAFKMode()');
    document.getElementById('battleSideTitle').setAttribute('onmouseover', "getZoneStats(event);this.style.cursor='pointer'");
    createSetting('ChangeLog', '显示更新日志', '(功能按钮)。 如果你还想看，再次显示在加载自动脚本的时候弹出的更新日志。本按钮为蓝色，说明这不是用来设置的，只是一个按钮而已。', 'action', 'printChangelog()', null, 'Display');
    createSetting('ShowSettings', '显示其他设置', '显示/隐藏一些我个人看来没什么用的设置(最高区域470)', 'boolean', true, null, 'Display')
    document.getElementById('Display').lastChild.insertAdjacentHTML('afterend','<br>');

//SPAM settings:
    //Subsection2Line1
    createSetting('SpamGeneral', '一般提示', '一般提示 = 通知信息, 自动氦/小时', 'boolean', true, null, 'Display');
    createSetting('SpamUpgrades', '升级提示', '升级提示', 'boolean', true, null, 'Display');
    createSetting('SpamEquipment', '装备提示', '装备提示', 'boolean', true, null, 'Display');
    createSetting('SpamMaps', '地图提示', '地图提示 = 购买,捡取，运行地图,回收,买不起', 'boolean', true, null, 'Display');
    createSetting('SpamOther', '其他提示', '其他提示 = 大部分的更好自动战斗 (disable with: MODULES[\\"fight\\"].enableDebug=false ), Trimpicide & AutoBreed/Gene Timer changes, AnalyticsID, etc - a catch all. ', 'boolean', true, null, 'Display');
    createSetting('SpamBuilding', '建筑提示', '建筑提示 = 所有的建筑,甚至是仓库', 'boolean', false, null, 'Display');
    createSetting('SpamJobs', '工作提示', '工作提示 = 所有工作,用科学计数法', 'boolean', false, null, 'Display');
    //Line2
    createSetting('SpamGraphs', '起始区域提示', 'Disables \'Starting new Zone ###\' , RoboTrimp MagnetoShreik, and any future Graph Spam that comes from graph logs.', 'boolean', true, null, 'Display');
    createSetting('SpamMagmite', 'Magmite/Magma 提示', 'Everything in Magmite Module and Buy Magmamancers', 'boolean', true, null, 'Display');
    createSetting('SpamPerks', '自动能力提示', '一切与自动能力有关的提示', 'boolean', true, null, 'Display');



// Export/Import/Default settings
    createSetting('ImportAutoTrimps', '导入自动脆皮配置', '导入你的脚本配置。 Asks you to name it as a profile afterwards.', 'infoclick', 'ImportAutoTrimps', null, 'Import Export');
    createSetting('ExportAutoTrimps', '导出自动脆皮配置', '把你的脆皮设置导出为JSON格式的字符串。', 'infoclick', 'ExportAutoTrimps', null, 'Import Export');
    createSetting('DefaultAutoTrimps', '重置自动脆皮配置', '把所有配置项目都重置到你第一次安装脚本的时候。', 'infoclick', 'ResetDefaultSettingsProfiles', null, 'Import Export');
    createSetting('CleanupAutoTrimps', '清理保存的设置 ', '从您的自动脆皮设置文件中删除以前版本的脚本的旧值', 'infoclick', 'CleanupAutoTrimps', null, 'Import Export');
    createSetting('allowSettingsUpload', '允许设置上传进行分析', 'Uploads your AUTOTRIMPS saved settings files (the same as Export AutoTrimps on this tab) <b>anonymously</b> - to https://autotrimps.site = the official Autotrimps development server. It will remain private for now, and aggregated for analytics to improve the script in the future and see which features are being used. Please Opt in. The upload will be approximately a small 5-10KB uncompressed text file every time the script is LOADED (for the time being until it is refined), and there is no concern for any personal data leak or privacy concern. This is all in good faith, and you are welcome to check the open source file modules/client-server.js. In the future, I will have to make a more fine-grained data-usage privacy-policy. Possible other data collected in the near-future may include certain game stats such as your highest zone, helium amount, bones, resource/magma/DE amounts, perk ratio selections. ', 'boolean', true, null, 'Import Export');
    settingsProfileMakeGUI();   //Settings Profile dropdown and Delete button. (this always shows up first - can be here last)
    //createSetting('ExportModuleVars', 'Export Custom Variables', 'Export your custom MODULES variables.', 'infoclick', 'ExportModuleVars', null, 'Import Export');
    //createSetting('ImportModuleVars', 'Import Custom Variables', 'Import your custom MODULES variables (and save).', 'infoclick', 'ImportModuleVars', null, 'Import Export');
    //createSetting('ResetModuleVars', 'Reset Custom Variables', 'Reset(Delete) your custom MODULES variables, and return the script to normal. ', 'infoclick', 'ResetModuleVars', null, 'Import Export');
    
    //createSetting('PlayerLevel', 'PlayerLevel', 'PlayerLevel: Indicate around what level you are. noob, low, medium, high, spire, magma, expert, z450+, z500+, endgame and so on. Might be used to control which settings are visible in the future. ', 'dropdown', "Medium", ["Noob","Low","Medium","High","Spire","Magma","Expert","z450+","z500+","EndGame"], 'Display');
    /*
    createSetting('ATModuleListDropdown', 'Modules', 'AT Module List Dropdown: Lists all the individual modules (.js files) that have been auto-loaded. It might be possible to unload these or something in the future.', 'dropdown', ATmoduleList[0], ATmoduleList, 'Import Export');
    document.getElementById('ATModuleListDropdown').multiple = true;    //allow 4 multiple selections
    document.getElementById('ATModuleListDropdown').size = 4;
    document.getElementById('ATModuleListDropdown').height = '5vw';    
    document.getElementById('ATModuleListDropdownLabel').style.verticalAlign = 'top';
    document.getElementById('ATModuleListDropdownLabel').parentNode.style.width = null; //make the next stuff fit on 1 line.
    createSetting('ATModuleUnload', 'Unload Module', 'UnLoads a running module file this session', 'infoclick', 'ATModuleUnload', null, 'Import Export');    
    createSetting('ATModuleLoad', 'ReLoad Module', 'Load/Reloads a module file (.js) and runs it.', 'infoclick', 'ATModuleLoad', null, 'Import Export');
    */
}
initializeAllSettings(); //EXECUTE

//Universal function that creates sets up the Settings database, structures and associated graphic elements
function createSetting(id, name, description, type, defaultValue, list, container) {
    var btnParent = document.createElement("DIV");
    // btnParent.setAttribute('class', 'optionContainer');
    btnParent.setAttribute('style', 'display: inline-block; vertical-align: top; margin-left: 1vw; margin-bottom: 1vw; width: 13.142vw;');
    var btn = document.createElement("DIV");
    btn.id = id;
    var loaded = autoTrimpSettings[id];
    if (type == 'boolean') {
        if (!(loaded && id == loaded.id))
            autoTrimpSettings[id] = {
                id: id,
                name: name,
                description: description,
                type: type,
                enabled: loaded === undefined ? (defaultValue || false) : loaded
            };
        btn.setAttribute("style", "font-size: 1.1vw;");
        btn.setAttribute('class', 'noselect settingsBtn settingBtn' + autoTrimpSettings[id].enabled);
        btn.setAttribute("onclick", 'settingChanged("' + id + '")');
        btn.setAttribute("onmouseover", 'tooltip(\"' + name + '\", \"customText\", event, \"' + description + '\")');
        btn.setAttribute("onmouseout", 'tooltip("hide")');
        btn.textContent = name;
        btnParent.appendChild(btn);
        if (container) document.getElementById(container).appendChild(btnParent);
        else document.getElementById("autoSettings").appendChild(btnParent);
    } else if (type == 'value' || type == 'valueNegative') {
        if (!(loaded && id == loaded.id))
            autoTrimpSettings[id] = {
                id: id,
                name: name,
                description: description,
                type: type,
                value: loaded === undefined ? defaultValue : loaded
            };
        btn.setAttribute("style", "font-size: 1.1vw;");
        btn.setAttribute('class', 'noselect settingsBtn btn-info');
        btn.setAttribute("onclick", 'autoSetValueToolTip("' + id + '", "' + name + '",'+`${(type == 'valueNegative')}`+')');
        btn.setAttribute("onmouseover", 'tooltip(\"' + name + '\", \"customText\", event, \"' + description + '\")');
        btn.setAttribute("onmouseout", 'tooltip("hide")');
        btn.textContent = name;
        btnParent.appendChild(btn);
        if (container) document.getElementById(container).appendChild(btnParent);
        else document.getElementById("autoSettings").appendChild(btnParent);
    } else if (type == 'dropdown') {
        if (!(loaded && id == loaded.id))
            autoTrimpSettings[id] = {
                id: id,
                name: name,
                description: description,
                type: type,
                selected: loaded === undefined ? defaultValue : loaded,
                list: list
            };
        var btn = document.createElement("select");
        btn.id = id;
        if (game.options.menu.darkTheme.enabled == 2) btn.setAttribute("style", "color: #C8C8C8; font-size: 1.0vw;");
        else btn.setAttribute("style", "color:black; font-size: 1.0vw;");
        btn.setAttribute("class", "noselect");
        btn.setAttribute("onmouseover", 'tooltip(\"' + name + '\", \"customText\", event, \"' + description + '\")');
        btn.setAttribute("onmouseout", 'tooltip("hide")');
        btn.setAttribute("onchange", 'settingChanged("' + id + '")');

        for (var item in list) {
            var option = document.createElement("option");
            option.value = list[item];
            option.text = cnname(list[item]);
            btn.appendChild(option);
        }
        btn.value = autoTrimpSettings[id].selected;

        var dropdownLabel = document.createElement("Label");
        dropdownLabel.id = id + "Label";
        dropdownLabel.innerHTML = name + ":";
        dropdownLabel.setAttribute('style', 'margin-right: 0.3vw; font-size: 0.8vw;');
        btnParent.appendChild(dropdownLabel);
        btnParent.appendChild(btn);
        if (container) document.getElementById(container).appendChild(btnParent);
        else document.getElementById("autoSettings").appendChild(btnParent);
    } else if (type == 'infoclick') {
        btn.setAttribute('class', 'btn btn-info');
        btn.setAttribute("onclick", 'ImportExportTooltip(\'' + defaultValue + '\', \'update\')');
        btn.setAttribute("onmouseover", 'tooltip(\"' + name + '\", \"customText\", event, \"' + description + '\")');
        btn.setAttribute("onmouseout", 'tooltip("hide")');
        btn.setAttribute("style", "display: block; font-size: 0.8vw;");
        btn.textContent = name;
        btnParent.style.width = '';
        btnParent.appendChild(btn);
        if (container) document.getElementById(container).appendChild(btnParent);
        else document.getElementById("autoSettings").appendChild(btnParent);
        return; //return means don't store it in autoTrimpSettings at the bottom
    } else if (type == 'multitoggle') {
        if (!(loaded && id == loaded.id))
            autoTrimpSettings[id] = {
                id: id,
                name: name,
                description: description,
                type: type,
                value: loaded === undefined ? defaultValue || 0 : loaded
            };
        btn.setAttribute("style", "font-size: 1.1vw;");
        btn.setAttribute('class', 'noselect settingsBtn settingBtn' + autoTrimpSettings[id].value);
        btn.setAttribute("onclick", 'settingChanged("' + id + '")');
        btn.setAttribute("onmouseover", 'tooltip(\"' + name.join(' / ') + '\", \"customText\", event, \"' + description + '\")');
        btn.setAttribute("onmouseout", 'tooltip("hide")');
        btn.textContent = autoTrimpSettings[id]["name"][autoTrimpSettings[id]["value"]];
        btnParent.appendChild(btn);
        if (container) document.getElementById(container).appendChild(btnParent);
        else document.getElementById("autoSettings").appendChild(btnParent);
    }
    else if(type === 'action')
    {
        //We're not storing the state on these.
        btn.setAttribute("style", "font-size: 1.1vw;");
        btn.setAttribute('class', 'noselect settingsBtn settingBtn3');  //color 3 is teal.
        btn.setAttribute('onclick', defaultValue);
        btn.setAttribute("onmouseover", 'tooltip(\"' + name + '\", \"customText\", event, \"' + description + '\")');
        btn.setAttribute("onmouseout", 'tooltip("hide")');
        btn.textContent = name;
        btnParent.appendChild(btn);
        if (container) document.getElementById(container).appendChild(btnParent);
        else document.getElementById("autoSettings").appendChild(btnParent);
        return; //return means don't store it in autoTrimpSettings at the bottom
    }

    //make sure names/descriptions match what we have stored.
    if (autoTrimpSettings[id].name != name)
        autoTrimpSettings[id].name = name;
    if (autoTrimpSettings[id].description != description)
        autoTrimpSettings[id].description = description;
    autoTrimpSettings["ATversion"] = ATversion;
}

//makes labeled checkboxes.
function createInput(id, name, description) {
    var $btnParent = document.createElement("DIV");
    $btnParent.setAttribute('style', 'display: inline-block; vertical-align: top; margin-left: 0.5vw; margin-bottom: 0.5vw; width: 6.5vw;');
    $btnParent.setAttribute("onmouseover", 'tooltip(\"' + name + '\", \"customText\", event, \"' + description + '\")');
    $btnParent.setAttribute("onmouseout", 'tooltip("hide")');
    var $input = document.createElement("input");
    $input.type = 'checkbox';
    $input.setAttribute('id', id);
    $input.setAttribute('style', 'text-align: left; width: 0.8vw; ');
    //$input.setAttribute('onkeypress', 'isValidKey2(this,event)');
    $btnParent.appendChild($input);
    var $label = document.createElement("label");
    $label.setAttribute('style', 'text-align: left; margin-left: 0.2vw; font-size: 0.6vw');
    $label.innerHTML = name;
    $btnParent.appendChild($label);
    document.getElementById("autoSettings").appendChild($btnParent);
}

//Default Toggler handler for any setting of the 3 special types (boolean, multitoggle, dropdown, and handle PrestigeBackup) - not value type.
function settingChanged(id) {
    var btn = autoTrimpSettings[id];
    if (btn.type == 'boolean') {
        btn.enabled = !btn.enabled;
        document.getElementById(id).setAttribute('class', 'noselect settingsBtn settingBtn' + btn.enabled);
    }
    if (btn.type == 'multitoggle') {
        //puts a 5 second pause in between cycling through from "on portal" to "always" so you can switch it to "off".
        if (id == 'AutoMagmiteSpender2' && btn.value == 1) {
            magmiteSpenderChanged = true;
            setTimeout(function() {
                magmiteSpenderChanged = false;
            }, 5000);
        }
        btn.value++;
        if (btn.value > btn.name.length - 1)
            btn.value = 0;
        document.getElementById(id).setAttribute('class', 'noselect settingsBtn settingBtn' + btn.value);
        document.getElementById(id).textContent = btn.name[btn.value];
    }
    if (btn.type == 'dropdown') {
        btn.selected = document.getElementById(id).value;
        //part of the prestige dropdown's "backup" system to prevent internal tampering via the dynamic prestige algorithm. everytime we see a user initiated change, make a backup.
        if (id == "Prestige")
            autoTrimpSettings["PrestigeBackup"].selected = document.getElementById(id).value;
    }
    //console.log(id + " Setting Changed");
    updateCustomButtons();
    saveSettings();
    checkPortalSettings();
    if ((autoTrimpSettings.AutoGen2.value == 3) && game.generatorUpgrades["Overclocker"].upgrades <= 0)
        tooltip('confirm', null, 'update', 'WARNING: You are set to Overclock but do not have any Overclocker upgrades. AutoGen2 will default to \'Max Cap\' in this case. If this is not desired, please fix your AutoGen2 setting.', 'cancelTooltip()', 'Cannot Overclock');
}

//Popup Tooltip - ask them to enter some numerical input. (STANDARDIZED)
function autoSetValueToolTip(id, text,negative) {
    ranstring = text;
    var elem = document.getElementById("tooltipDiv");
    var tooltipText = '在下面输入一个数字。你也可以使用像2e5、200k这样的简略表示法。';
    if (negative)
        tooltipText += 'Accepts negative numbers as validated inputs.';
    else
        tooltipText += '输入-1表示无限。';
    tooltipText += '<br/><br/><input id="customNumberBox" style="width: 50%" onkeypress="onKeyPressSetting(event, \'' + id + '\','+negative+')" value=' + autoTrimpSettings[id].value + '></input>';
    var costText = '<div class="maxCenter"><div class="btn btn-info" onclick="autoSetValue(\'' + id + '\','+negative+')">Apply</div><div class="btn btn-info" onclick="cancelTooltip()">Cancel</div></div>';
    game.global.lockTooltip = true;
    elem.style.left = '32.5%';
    elem.style.top = '25%';
    document.getElementById('tipTitle').textContent = ranstring + ':  Value Input';
    document.getElementById('tipText').innerHTML = tooltipText;
    document.getElementById('tipCost').innerHTML = costText;
    elem.style.display = 'block';
    var box = document.getElementById('customNumberBox');
    try {
        box.setSelectionRange(0, box.value.length);
    } catch (e) {
        box.select();
    }
    box.focus();
}
//Keyboard handler - Enter Key accepts popup
function onKeyPressSetting(event, id,negative) {
    if (event.which == 13 || event.keyCode == 13) {
        autoSetValue(id,negative);
    }
}
//Custom Number Box - Suffix handler for numerical to string values in the prompted popup
function autoSetValue(id,negative) {
    var num = 0;
    unlockTooltip();
    tooltip('hide');
    var numBox = document.getElementById('customNumberBox');
    if (numBox) {
        num = numBox.value.toLowerCase();
        if (num.split('e')[1]) {
            num = num.split('e');
            num = Math.floor(parseFloat(num[0]) * (Math.pow(10, parseInt(num[1]))));
        } else {
            var letters = num.replace(/[^a-z]/gi, '');
            var base = 0;
            if (letters.length) {
                var suffices = ['K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc', 'Ud', 'Dd', 'Td', 'Qad', 'Qid', 'Sxd', 'Spd', 'Od', 'Nd', 'V', 'Uv', 'Dv', 'Tv', 'Qav', 'Qiv', 'Sxv', 'Spv', 'Ov', 'Nv', 'Tt'];
                for (var x = 0; x < suffices.length; x++) {
                    if (suffices[x].toLowerCase() == letters) {
                        base = x + 1;
                        break;
                    }
                }
                if (base) num = Math.round(parseFloat(num.split(letters)[0]) * Math.pow(1000, base));
            }
            if (!base) num = parseFloat(num);
        }
    } else return;
    autoTrimpSettings[id].value = num;
    if (num > -1 || negative)
        document.getElementById(id).textContent = ranstring + ': ' + prettify(num);
    else
        document.getElementById(id).innerHTML = ranstring + ': ' + "<span class='icomoon icon-infinity'></span>";
    saveSettings();
    checkPortalSettings();
}

//toggles the display of the settings menu. 1
function autoToggle(what) {
    if (what) {
        var $what = document.getElementById(what);
        if ($what.style.display === 'block') {
            $what.style.display = 'none';
            document.getElementById(what + 'BTN').style.border = '';
        } else {
            $what.style.display = 'block';
            document.getElementById(what + 'BTN').style.border = '4px solid green';
        }
    } else {
        if (game.options.displayed)
            toggleSettingsMenu();
        var $item = document.getElementById('graphParent');
        if ($item.style.display === 'block')
            $item.style.display = 'none';
        var $item = document.getElementById('autoTrimpsTabBarMenu');
        if ($item.style.display === 'block')
            $item.style.display = 'none';
        else $item.style.display = 'block';
        var $item = document.getElementById('autoSettings');
        if ($item.style.display === 'block')
            $item.style.display = 'none';
        else $item.style.display = 'block';
    }
}

//toggles the display of the original settings menu button,
// when clicked, hiding the AT settings and graph.
function autoPlusSettingsMenu() {
    var $item = document.getElementById('autoSettings');
    if ($item.style.display === 'block')
        $item.style.display = 'none';
    var $item = document.getElementById('graphParent');
    if ($item.style.display === 'block')
        $item.style.display = 'none';
    var $item = document.getElementById('autoTrimpsTabBarMenu');
    if ($item.style.display === 'block')
        $item.style.display = 'none';
    toggleSettingsMenu();
}

//Responsible for keeping the GUI in sync with the settings database and
// force-controlling the values of some and changing its visible or hidden status

function updateCustomButtons() {
    //console.log("GUI: CustomButtons Updated");
    if (lastTheme && game.options.menu.darkTheme.enabled != lastTheme) {
    if (typeof MODULES["graphs"] !== 'undefined')
        MODULES["graphs"].themeChanged();
        debug("Theme change - AutoTrimps styles updated.");
    }
    lastTheme = game.options.menu.darkTheme.enabled;
    function toggleElem(elem, showHide) {
        var $item = document.getElementById(elem);
        if ($item == null) return;
        var state = showHide ? '' : 'none';
        var stateParent = showHide ? 'inline-block' : 'none';
        $item.style.display = state;
        $item.parentNode.style.display = stateParent;
    }
    function turnOff(elem) {
        toggleElem(elem, false);
    }
    function turnOn(elem) {
        toggleElem(elem, true);
    }
    //automaps button in GUI
    document.getElementById("autoMapBtn").setAttribute("class", "noselect settingsBtn settingBtn" + autoTrimpSettings.AutoMaps.value);
    //auto portal setting, hide until player has unlocked the balance challenge
    (game.challenges.Balance.filter()) ? turnOn("AutoPortal") : turnOff("AutoPortal");
    //auto Daily settings, hide until player has unlocked the Daily challenges
    var doDaily = game.challenges.Daily.filter();
    (doDaily) ? turnOn("AutoStartDaily") : turnOff("AutoStartDaily");
    (doDaily) ? turnOn("AutoFinishDaily") : turnOff("AutoFinishDaily");
    //if custom auto portal is not selected, remove the custom value settingsbox
    (autoTrimpSettings.AutoPortal.selected == "Custom") ? turnOn("CustomAutoPortal") : turnOff("CustomAutoPortal");
    //if HeHr is not selected, remove HeliumHourChallenge settingsbox
    var heHr = (autoTrimpSettings.AutoPortal.selected == "Helium Per Hour");
    (heHr || autoTrimpSettings.AutoPortal.selected == "Custom") ? turnOn("HeliumHourChallenge") : turnOff("HeliumHourChallenge");
    //if HeHr is not selected, remove HeHrDontPortalBefore settingsbox
    (heHr) ? turnOn("HeHrDontPortalBefore") : turnOff("HeHrDontPortalBefore");
    //if HeHr is not selected, remove HeHr buffer settingsbox
    (heHr) ? turnOn("HeliumHrBuffer") : turnOff("HeliumHrBuffer");
    //if ShieldBlock is for sure, remove ShieldBlock from settingsbox (achievement=12 means z100).
    //(game.achievements.zones.finished < 12) ? turnOn("BuyShieldblock") : function(){turnOff("BuyShieldblock");setPageSetting("BuyShieldblock",false);}();
    //if AS3 is not selected, remove Windstack settingsbox
    getPageSetting('AutoStance')==3 ? turnOn("WindStackingMin"): turnOff("WindStackingMin");
    getPageSetting('AutoStance')==3 ? turnOn("ScryUseinPoison"): turnOff("ScryUseinPoison");
    getPageSetting('AutoStance')==3 ? turnOn("ScryUseinWind"): turnOff("ScryUseinWind");
    getPageSetting('AutoStance')==3 ? turnOn("ScryUseinIce"): turnOff("ScryUseinIce");
    getPageSetting('AutoStance')!=3 ? turnOn("IgnoreCrits") : turnOff("IgnoreCrits");
    /*//Make Scryer settings a little more user friendly
    if (getPageSetting('ScryerUseinVoidMaps2') !=0) { setPageSetting("ScryerUseinMaps2", "2"); }
    if (getPageSetting('ScryerUseinSpire2') !=1 && isActiveSpireAT()) { setPageSetting("ScryerSkipCorrupteds2", "2"); } */
    //Show and Hide useless settings to reduce UI clutter
    var turnonofflist = [
      "ManualGather2","BuyUpgradesNew","TrapTrimps","UsePatience",
      "BuyBuildingsNew","WarpstationCap","WarpstationCoordBuy","MaxHut","MaxHouse","MaxMansion","MaxHotel","MaxResort","MaxGateway","MaxWormhole","MaxCollector","MaxGym","MaxTribute","GymWall","FirstGigastation","DeltaGigastation","WarpstationWall3",
      "CapEquip2","DelayArmorWhenNeeded","BuyShieldblock",
      "DynamicSiphonology","PreferMetal","LowerFarmingZone","FarmWhenNomStacks7","RunBionicBeforeSpire","CorruptionCalc","MaxTox","VoidCheck","TrimpleZ",
      "DynamicGyms",
      "SupplyWall","BuyOneTimeOC","MagmiteExplain",
      "SpamGeneral","SpamUpgrades","SpamEquipment","SpamMaps","SpamOther","SpamBuilding","SpamJobs","SpamGraphs","SpamMagmite","SpamPerks",
    ];
    if (game.worldUnlocks.easterEgg)
        turnonofflist.push("AutoEggs");
    for (var i in turnonofflist)
        getPageSetting('ShowSettings') ? turnOn(turnonofflist[i]) : turnOff(turnonofflist[i]);

    //DROPDOWNS: updates dropdown selections. (ALL DROPDOWNS REQUIRE THIS BIT TO BE UPDATEY)
    //todo check why this isnt possible to set automatically in the dropdown code.
    document.getElementById('AutoPortal').value = autoTrimpSettings.AutoPortal.selected;
    document.getElementById('HeliumHourChallenge').value = autoTrimpSettings.HeliumHourChallenge.selected;
    document.getElementById('AutoGoldenUpgrades').value = autoTrimpSettings.AutoGoldenUpgrades.selected;
    document.getElementById('AutoPoison').value = autoTrimpSettings.AutoPoison.selected;
    document.getElementById('AutoWind').value = autoTrimpSettings.AutoWind.selected;
    document.getElementById('AutoIce').value = autoTrimpSettings.AutoIce.selected;
    //DerSkagg Mod: Golden Upgrade Settings. (Toggles relevant ones on/off)
    if (autoTrimpSettings.AutoGoldenUpgrades.selected == "Void") {
        turnOn("goldStrat");
        document.getElementById('goldStrat').value = autoTrimpSettings.goldStrat.selected;
        if (autoTrimpSettings.goldStrat.selected == "Alternating") {
            document.getElementById('goldAlternating').value = autoTrimpSettings.goldAlternating.selected;
            turnOn("goldAlternating")
        } else
            turnOff("goldAlternating");
        (autoTrimpSettings.goldStrat.selected == "Zone") ? turnOn("goldZone") : turnOff("goldZone");
        (autoTrimpSettings.goldStrat.selected != "Off") ? turnOn("goldNoBattle") : turnOn("goldNoBattle");
    } else {
        turnOff("goldStrat");
        turnOff("goldAlternating");
        turnOff("goldZone");
        turnOff("goldNoBattle");
    }
    //document.getElementById('Prestige').value = autoTrimpSettings.Prestige.selected; //dont update this, dynamic prestige takes it over and is handled elsewhere.

    //stop disable farming from needing a refresh
    if (getPageSetting('DisableFarm'))
        shouldFarm = false;

    // handle metal preference
    MODULES["maps"] && (MODULES["maps"].preferGardens = !getPageSetting('PreferMetal'));
    //if player has selected arbalest or gambeson but doesn't have them unlocked, just unselect it for them! It's magic!
    if (document.getElementById('Prestige').selectedIndex > 11 && game.global.slowDone == false) {
        document.getElementById('Prestige').selectedIndex = 11;
        autoTrimpSettings.Prestige.selected = "Bestplate";
    }
    //Bionic Before Spire - Auto turns on ability to run UniqueMaps
    if (autoTrimpSettings.RunBionicBeforeSpire.enabled && getPageSetting('AutoMaps')==2) {
        debug("RunBionicBeforeSpire incompatible with AutoMaps No Unique Maps, changing...");
        setPageSetting("AutoMaps",1);
    }
    //since this is a loop, make sure the Text contents of our buttons are set accurately. (after any setPageSetting)
    for (var setting in autoTrimpSettings) {
        var item = autoTrimpSettings[setting];
        if (item.type == 'value' || item.type == 'valueNegative' || item.type == 'multitoggle') {
            var elem = document.getElementById(item.id);
            if (elem != null) {
                if (item.type == 'multitoggle')
                    elem.textContent = item.name[item.value];
                else if (item.value > -1 || item.type == 'valueNegative')
                    elem.textContent = item.name + ': ' + prettify(item.value);
                else
                    elem.innerHTML = item.name + ': ' + "<span class='icomoon icon-infinity'></span>";
            }
        }
    }
}

//Checks portal related UI settings
function checkPortalSettings() {
    var result = findOutCurrentPortalLevel();
    var portalLevel = result.level;
    var leadCheck = result.lead;
    if (portalLevel == -1)
        return portalLevel;
    var voidmaps = getPageSetting('VoidMaps');
    if (voidmaps >= portalLevel)
        tooltip('confirm', null, 'update', 'WARNING: Your void maps are set to complete after your autoPortal, and therefore will not be done at all! Please Change Your Settings Now. This Box Will Not Go away Until You do. Remember you can choose \'Custom\' autoPortal along with challenges for complete control over when you portal. <br><br> Estimated autoPortal level: ' + portalLevel, 'cancelTooltip()', 'Void Maps Conflict');
    if ((leadCheck || game.global.challengeActive == 'Lead') && (voidmaps % 2 == 0 && portalLevel <= 181))
        tooltip('confirm', null, 'update', 'WARNING: Voidmaps run during Lead on an Even zone do not receive the 2x Helium Bonus for Odd zones, and are also tougher. You should probably fix this.', 'cancelTooltip()', 'Lead Challenge Void Maps');
    return portalLevel;
}

//Hider's He/Hr Info stats (in world sidebar)
function getDailyHeHrStats() {
    var words = "";
    if (game.global.challengeActive == "Daily") {
        var getPercent = (game.stats.heliumHour.value() / (game.global.totalHeliumEarned - (game.global.heliumLeftover + game.resources.helium.owned)));
        getPercent *= 100 + getDailyHeliumValue(countDailyWeight());
        words = "<b>完成日常挑战后氦/小时：" + getPercent.toFixed(3) +'%';
    }
    return words;
}

//Part of import-export.js module.
function settingsProfileMakeGUI(){};    //blank on purpose, will be overwritten if necessary.

//controls the button skips 2 of the tri-state automaps button
function toggleAutoMaps(){
  if (getPageSetting('AutoMaps'))
    setPageSetting('AutoMaps',0);
  else
    setPageSetting('AutoMaps',1);
  document.getElementById("autoMapBtn").setAttribute("class", "noselect settingsBtn settingBtn" + autoTrimpSettings.AutoMaps.value);
}
